package com.tshopping.dao;

import com.tshopping.bean.Goods;
import com.tshopping.bean.Store;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
public interface SearchDao {
    @Select("select * from store where name like concat('%',#{keyWord},'%') or description like concat('%',#{keyWord},'%') or address like concat('%',#{keyWord},'%') limit #{start},#{size}")
    ArrayList<Store> selectStoreByKeyWords(@Param("keyWord") String keyWord, @Param("start") int start, @Param("size") int size);

    @Select("select count(*) from store where name like concat('%',#{keyWord},'%') or description like concat('%',#{keyWord},'%') or address like concat('%',#{keyWord},'%')")
    int selectStoreCountByKeyWords(@Param("keyWord") String keyWord);

    @Select("select * from goods where name like concat('%',#{keyWord},'%') limit #{start},#{size}")
    ArrayList<Goods> selectGoodsByKeyWords(@Param("keyWord") String keyWord, @Param("start") int start, @Param("size") int size);

    @Select("select count(*) from goods where name like concat('%',#{keyWord},'%')")
    int selectGoodsCountByKeyWords(@Param("keyWord")String keyWord);
}
